package cn.jw.starter.common.utils;

import java.io.IOException;

import jakarta.servlet.http.HttpServletResponse;

/**
 * <p>
 * http response 工具类
 * </p>
 *
 * @author 王广帅
 * @since 2024/4/10 14:02
 **/
public class HttpResponseUtil {

    /**
     * 将字符串渲染到客户端
     *
     * @param response
     *            渲染对象
     * @param string
     *            待渲染的字符串
     */
    public static void renderString(HttpServletResponse response, String string) {
        try {
            response.setStatus(200);
            response.setContentType("application/json");
            response.setCharacterEncoding("utf-8");
            response.getWriter().print(string);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
